package com.bgi.uims.common.dto;

import java.io.Serializable;
import java.util.Map;

import org.apache.struts2.json.annotations.JSON;

import com.bgi.uims.common.action.BaseAction;


/**
 * 
 * ClassName: Common <br/>
 * Function: TODO 通用父类对象，所有dto均集成该类. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2014-10-20 下午02:08:00 <br/>
 *
 * @author fukun
 * @version 
 * @since JDK 1.7
 */
public class Common implements Serializable{

	private static final long serialVersionUID = 3948919749820871174L;
	//SQL
	/**
	 * 指定insert SQL ID
	 */
	private String insertSql;
	/**
	 * 指定update SQL ID
	 */
	private String deleteSql;
	/**
	 * 指定update SQL ID
	 */
	private String updateSql;
	/**
	 * 指定query one Object SQL ID
	 */
	private String queryOneSql;
	/**
	 * 指定query List Object SQL ID
	 */
	private String querySql;
	/**
	 * 指定批量insert SQL ID
	 */
	private String insertListSql;
	
	//Page Query
	/**
	 * 查询当前页码
	 */
	private Integer currPage;//当前页
	/**
	 * 查询页码显示条数
	 */
	private Integer pageSize;//每页条数
	/**
	 * 查询起始行号
	 */
	private Integer startRow;//起始行号（根据当前页码自动计算）
	/**
	 * 查询截止行号
	 */
	private Integer endRow;//截止行号（根据当前页码自动计算）
	/**
	 * 总数
	 */
	private Long total;//总数
	
	/**
	 * 获取监测对象(新旧对比)信息的具体内容
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public Map annotationObject(){return null;}
	
	@JSON(serialize=false)
	public String getInsertSql() {
		return insertSql;
	}
	public void setInsertSql(String insertSql) {
		this.insertSql = insertSql;
	}
	@JSON(serialize=false)
	public String getDeleteSql() {
		return deleteSql;
	}
	public void setDeleteSql(String deleteSql) {
		this.deleteSql = deleteSql;
	}
	@JSON(serialize=false)
	public String getUpdateSql() {
		return updateSql;
	}
	public void setUpdateSql(String updateSql) {
		this.updateSql = updateSql;
	}
	@JSON(serialize=false)
	public String getQueryOneSql() {
		return queryOneSql;
	}
	public void setQueryOneSql(String queryOneSql) {
		this.queryOneSql = queryOneSql;
	}
	@JSON(serialize=false)
	public String getQuerySql() {
		return querySql;
	}
	public void setQuerySql(String querySql) {
		this.querySql = querySql;
	}
	@JSON(serialize=false)
	public Integer getCurrPage() {
		return currPage;
	}
	public void setCurrPage(Integer currPage) {
		this.currPage = currPage;
	}
	@JSON(serialize=false)
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	@JSON(serialize=false)
	public Integer getStartRow() {
		if(currPage!=null&&pageSize!=null)
		{
			startRow=(currPage-1)*pageSize;
		}
		return startRow;
	}
	public void setStartRow(Integer startRow) {
		this.startRow = startRow;
	}
	@JSON(serialize=false)
	public Integer getEndRow() {
		if(currPage!=null&&pageSize!=null)
		{
			endRow=currPage*pageSize;
		}
		return endRow;
	}
	public void setEndRow(Integer endRow) {
		this.endRow = endRow;
	}
	@JSON(serialize=false)
	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}
	
	//获得页码
	public void getPage(BaseAction baseAction){
		if(baseAction!=null)
		{
			/*if(authAction.getParameter(Constant.ROWS)!=null)
			{
				this.pageSize = Integer.parseInt(authAction.getParameter(Constant.ROWS));
			}
			if(authAction.getParameter(Constant.PAGE)!=null)
			{
				this.currPage = Integer.parseInt(authAction.getParameter(Constant.PAGE));
			}*/
			if(baseAction.getRows()!=null&&baseAction.getRows().length==1)
			{
				this.pageSize = baseAction.getRows()[0];
			}
			if(baseAction.getPage()!=null&&baseAction.getPage().length==1)
			{
				this.currPage = baseAction.getPage()[0];
			}
		}
	}

	/**  
	 * insertListSql  
	 * @return  the insertListSql  
	 */
	public String getInsertListSql() {
		return insertListSql;
	}

	/**  
	 * @param insertListSql the insertListSql to set  
	 */
	public void setInsertListSql(String insertListSql) {
		this.insertListSql = insertListSql;
	}
}
